/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package july.android.cakes.tools;

import java.io.File;

/**
 *
 * @author S_Cake
 * @version 文件重命名
 */
public class Rename {
    static public void renameFile(String path,String oldname,String newname){ 
        if(!oldname.equals(newname)){
            File oldfile=new File(path+ File.separator +oldname); 
            File newfile=new File(path+ File.separator +newname); 
            if(!oldfile.exists()){
                System.out.println(newname+"不存在！"); 
                return;
            }
            if(newfile.exists())
                System.out.println(newname+"已经存在！"); 
            else{ 
                oldfile.renameTo(newfile); 
            } 
        }else{
            System.out.println("新文件名和旧文件名相同...");
        }
    }
}
